<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"  %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ path + "/";
%> 
<html lang="en">
    <head>
        <meta charset="utf-8">
        <link rel="stylesheet" href="<%=basePath %>css/pagination.css">
        <link rel="stylesheet" href="<%=basePath %>css/cssreset.css">
        
        <link rel="stylesheet" href="<%=basePath %>css/style2.css">
        <script language="javascript" src="<%=basePath %>js/PCASClass.js"></script>
		<script src="<%=basePath %>js/jquery-1.11.1.min.js"></script>
		 <script>
		       $(function(){
			    	$(".opennew").click(function(e){
			        e.preventDefault();
			        $('body').css("overflow","hidden")
			        $("#cover").css("display","block");
			        $("#cover").animate({
			            width: "100%",
			            height: "1800px",
			            top: "0",
			            left: "0"
			        },10);
			        /*$("#cover-content").animate({
			            width: "300px",
			            height: "300px",
			        },800);*/
			    });
			    $(".close").click(function(){
			    	$('body').css("overflow","scroll");
			        $("#cover").removeAttr("style");
			        $("#cover-content").removeAttr("style");
			    });
			    $(".btn4").click(function(event) {
			    	$("#cover").removeAttr("style");
			        $("#cover-content").removeAttr("style");
			    	$('.hhh').css('display', 'block');
			    });
			    $(".chongqi").click(function(event) {
			    	$(".hhh").css('display', 'none');
			    });
			});
		  </script> 
        
    </head>
    <body>
    	<div class="bigbox2">
    		<nav class="nav2">
    			<span class="scolor"></span>
    			<ul>
    				<li><a href="<%=basePath %>page/originalIndex.jsp"><p class="mline"><span class="smallicon"></span><span class="navtxt">首 页</span></p></a></li>
    				<li><a href="<%=basePath %>client/findByIndex.action"><p class="mline"><span class="smallicon one1" ></span><span class="navtxt" >客 户</span></p></a></li>
    				<li><a href="<%=basePath %>sale/findSale.action"><p class="mline"><span class="smallicon one2"></span><span class="navtxt">销 售 机 会</span></p></a></li>
    				<li><a href="<%=basePath %>contact/page.action"  id="sline"><p class="mline"><span class="smallicon one3" id="current21"></span><span class="navtxt" id="current2">联 系 人</span></p></a></li>
    				<li><a href="<%=basePath %>contract/findByAlls.action"><p class="mline"><span class="smallicon one4"></span><span class="navtxt">合 同</span></p></a></li>
    				<li class="shenpi"><a href="<%=basePath %>page/pacts.jsp"><p class="mline"><span class="smallicon one8"></span><span class="navtxt">合 同 审 批</span></p></a></li>
    				<c:if test="${sessionScope.backstage == 1}">
   						<li><a href="<%=basePath %>staff/selectTree.action"><p class="mline"><span class="smallicon one5"></span><span class="navtxt">后 台 管 理</span></p></a></li>
    				</c:if>
    			</ul>
    		</nav>
    		<div class="showbox3">
	    		<p class="xtitle">联 系 人 详 情</p>
	    		<span class="boxone">
	    		<div class="above">
		    		</span>
		    		<span class="open" onclick="updatePage()">
		    			<span class="opennew">编 辑</span>
		    			
		    		</span>
	    		</div>
		    	<ul class="sun sun2">
		    		<li>
		    			<span class="sone">公司名称</span><br>
		    			<span class="stwo">${list.client_name}</span>
		    		</li>
		    		<li>
		    			<span class="sone">职务</span><br>
		    			<span class="stwo">${list.contact_job}</span>
		    		</li>
		    		<li>
		    			<span class="sone">手机</span><br>
		    			<span class="stwo">${list.contact_cellphone}</span>
		    		</li>
		    		<li>
		    			<span class="sone">电子邮箱</span><br>
		    			<span class="stwo">${list.contact_email}</span>
		    		</li>
		    		<li>
		    			<span class="sone">联系人所有人</span><br>
		    			<span class="stwo">${list.staff_name}</span>
		    		</li>
		    		
		    	</ul>		
	    		</span> 
	    		<div class="b-box"></div>	   		
    		</div>
    		<div class="showbox3 showbox4">
	    		  <div class="boxtwo">
	    		  
	    		  	
	    		  	<div class="boxthree">
	    		  		<span class="threenav threenav2">
	    		  			<a href="<%=basePath %>html/client2.html" class="fg fg2">资料</a>
	    		  		</span>
	    		  		<div class="formdan">
	    		  			<p>基本信息</p>
	    		  			<ul class="basictxt">
	    		  				<li>
	    		  					<span class="crazy">联系人类型</span>
	    		  					<span class="crazy2">${list.contact_type}</span>
	    		  				</li>
	    		  				<li>
	    		  					<span class="crazy">联系人所有人</span>
	    		  					<span class="crazy2">${list.staff_name}</span>
	    		  				</li>
	    		  				<li>
	    		  					<span class="crazy">姓名</span>
	    		  					<span class="crazy2">${list.contact_name}</span>
	    		  				</li>
	    		  				<li>
	    		  					<span class="crazy">性别</span>
	    		  					<span class="crazy2" id="contactSex">${list.contact_sex}</span>
	    		  				</li>
	    		  				<li>
	    		  					<span class="crazy">客户名称</span>
	    		  					<span class="crazy2" id="clientName">${list.client_name}</span>
	    		  				</li>
	    		  				<li>
	    		  					<span class="crazy">部门</span>
	    		  					<span class="crazy2" id="departmentName">${list.department_name}</span>
	    		  				</li>
	    		  				<li>
	    		  					<span class="crazy">职务</span>
	    		  					<span class="crazy2">${list.contact_job}</span>
	    		  				</li>
	    		  			</ul>
	    		  			<p>公海信息</p>
	    		  			<ul class="basictxt">
	    		  				
	    		  				<li>
	    		  					<span class="crazy">创建日期</span>
	    		  					<span class="crazy2">${list.communal_creationDate}</span>
	    		  				</li>
	    		  				<li>
	    		  					<span class="crazy">创建人</span>
	    		  					<span class="crazy2">${list.communal_creater}</span>
	    		  				</li>
	    		  				<li>
	    		  					<span class="crazy">最新修改日</span>
	    		  					<span class="crazy2">${list.communal_amendDate}</span>
	    		  				</li>
	    		  				<li>
	    		  					<span class="crazy">最新修改人</span>
	    		  					<span class="crazy2">${list.communal_amendName}</span>
	    		  				</li>
	    		  				<li>
	    		  					<span class="crazy">备注</span>
	    		  					<span class="crazy2">${list.communal_remarks}</span>
	    		  				</li>
	    		  			</ul>
	    		  			<p>联系信息</p>
	    		  			<ul class="basictxt">
	    		  				<li>
	    		  					<span class="crazy">电话</span>
	    		  					<span class="crazy2">${list.information_phone}</span>
	    		  				</li>
	    		  				<li>
	    		  					<span class="crazy">手机</span>
	    		  					<span class="crazy2">${list.contact_cellphone}</span>
	    		  				</li>
	    		  				<li>
	    		  					<span class="crazy">电子邮件</span>
	    		  					<span class="crazy2">${list.contact_email}</span>
	    		  				</li>
	    		  				<li>
	    		  					<span class="crazy">微博</span>
	    		  					<span class="crazy2">${list.information_microblog}</span>
	    		  				</li>
	    		  				<li>
	    		  					<span class="crazy">所在区域</span>
	    		  					<span class="crazy2">
	    		  						<span >${list.information_province}</span>
	    		  						<span >${list.information_city}</span>
	    		  						<span >${list.information_area}</span>
	    		  					</span>
	    		  				</li>
	    		  				<li>
	    		  					<span class="crazy">地址</span>
	    		  					<span class="crazy2">${list.information_address}</span>
	    		  				</li>
	    		  				<li>
	    		  					<span class="crazy">邮政编码</span>
	    		  					<span class="crazy2">${list.information_postalcode}</span>
	    		  				</li>
	    		  				
	    		  			</ul>
	    		  		</div>
	    		  		
	    		  		

	    		  	</div>
	    		  </div>		
    		</div>
    		<div id="cover">
			    		<div id="cover-bg"></div>
						<div id="cover-content">
								<h4 style="position:fixed;width:625px;">编 辑 联 系 人<span class="close"></span></h4>
								<p class="main" style="z-index:-1">
									<span class="leftmain">联系人类型</span>
									<span class="name" style="margin-left:-25px;" id="contact_type" value="${list.contact_type}">默认业务类型</span>
						        </p>
						        <p class="main" style="z-index:-1">
					    			<span class="leftmain">联系人所有人</span>						
					    			<span class="xsicon" style="left:25px;"><img src="<%=basePath %>images/head.png" alt="" class="kkk">&nbsp;</span>
					    			<span class="name namee" id="staff_name">${list.staff_name}</span>
				    		    </p>
				    		    <p class="main" style="z-index:-1">
									<span class="leftmain">姓 名&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
									<input type="text" placeholder="&nbsp;&nbsp;请输入姓名 " class="shurukuang" id="contact_name" value="${list.contact_name}">
								</p>
								<p class="main" style="z-index:-1">
									<span class="leftmain">客 户 名 称</span>
									<select id="clientID" class="shenfenselect shenfenselect3">
							            <option value="">请选择客户</option>
							            <c:forEach items="${client1}" var="client1">
							            	<option value="${client1.client_id}">${client1.client_name}</option>
							            </c:forEach>
							        </select>
								</p>
								<p class="main" style="z-index:-1">
									<span class="leftmain">所 属 部 门</span>
									<select id="departmentID" class="shenfenselect shenfenselect3">
							            <option value="">请选择部门</option>
							            <c:forEach items="${departments1}" var="department">
							            	<option value="${department.department_id}">${department.department_name}</option>
							            </c:forEach>
							        </select>
								</p>
							   <p class="main" style="z-index:-1">
									<span class="leftmain">职 务&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
									<input type="text" placeholder="&nbsp;&nbsp;请输入职务名称" class="shurukuang" id="contact_job" value="${list.contact_job}">
								</p>
							    <p class="main" style="z-index:-1">
									<span class="leftmain">电 话&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
									<input type="text" placeholder="&nbsp;&nbsp;请输入电话号码" class="shurukuang" id="information_phone" value="${list.information_phone}">
								</p>
							    <p class="main" style="z-index:-1">
									<span class="leftmain">手 机&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
									<input type="text" placeholder="&nbsp;&nbsp;请输入手机号码 " class="shurukuang" id="contact_cellphone" value="${list.contact_cellphone}">
								</p>
							    <p class="main" style="z-index:-1">
									<span class="leftmain">电 子 邮 件</span>
									<input type="text" placeholder="&nbsp;&nbsp;请输入电子邮件 " class="shurukuang" id="contact_email" value="${list.contact_email}">
								</p>
							    <p class="main" style="z-index:-1">
									<span class="leftmain">微 博&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
									<input type="text" placeholder="&nbsp;&nbsp;请输入微博 " class="shurukuang" id="information_microblog" value="${list.information_microblog}">
								</p>
								<p class="main" style="z-index:-1">
									<span class="leftmain">省 份&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
									<select id="sheng" name="province3" class="shenfenselect shenfenselect4">
							        </select>
							        <select id="shi" name="city3" class="shenfenselect shenfenselect2 shenfenselect4">
							        </select>
							        <select id="xiang" name="area3" class="shenfenselect shenfenselect2 shenfenselect4">
							        </select>
								</p>
								<p class="main" style="z-index:-1">
									<span class="leftmain">详 细 地 址</span>
									<input type="text" placeholder="&nbsp;&nbsp;请输入详细地址 " class="shurukuang" id="information_address" value="${list.information_address}">
								</p>
								<p class="main" style="z-index:-1">
									<span class="leftmain">邮 政 编 码</span>
									<input type="text" placeholder="&nbsp;&nbsp;请输入邮政编码 " class="shurukuang" id="information_postalcode" value="${list.information_postalcode}">
								</p>
								<p class="main" style="z-index:-1">
									<span class="leftmain">性 别&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
									<select id="contact_sex" class="shenfenselect shenfenselect3">
											            <option value="男">男</option>
											            <option value="女">女</option>
									</select>
							    </p>
								<p class="main" style="z-index:-1">
									<span class="leftmain">备 注&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
									<input type="text" placeholder="&nbsp;&nbsp;请输入备注 " class="shurukuang" id="communal_remarks" value="${list.communal_remarks}">
								</p>
								<p class="main" style="padding-bottom:30px;margin-left:145px;z-index:-1;">
									<button class="btn1 btn2" onclick="show()">保存</button>
									<button class="btn1 btn3">取消</button>
								</p>
			    		</div>
					 	</div>
    		</div>
    		<div style="display:none;">
    			<span id="contact_id">${list.contact_id}</span>
    			<span id="communalID">${list.communalID}</span>
    			<span id="informationIDaa">${list.informationID}</span>
    		</div>
    </body>
    <script src="${pageContext.request.contextPath}/salejihui/My97DatePicker/WdatePicker.js"></script>
		<script src="${pageContext.request.contextPath}/salejihui/js/jquery.validate.min.js"></script>
		<script src="${pageContext.request.contextPath}/salejihui/js/messages_zh.min.js"></script>
    <script type="text/javascript">	   
	   
    	function show(){
		   var contact_id= $("#contact_id").html();
		   if(contact_id == ""){
			   alert("发生未知错误，即将返回列表页");
			   location.href="<%=basePath %>contact/page.action";
		   }
		   var communalID= $("#communalID").html();
		   var informationID= $("#informationIDaa").html();
		   var onecli = $("#onecli").val();
	       if(onecli == 0){
	    		alert("客户不能为空");
	    		return;
	    	}
	       	
		   	var contact_type = "默认业务类型";
		   	var contact_name = $("#contact_name").val();
		   	var clientID = $("#clientID").val();
		   	var departmentID = $("#departmentID").find("option:selected").val();
		   	var contact_job = $("#contact_job").val();
		   	var information_phone = $("#information_phone").val();
		   	var contact_cellphone = $("#contact_cellphone").val();
		   	var contact_email = $("#contact_email").val();
		   	var information_microblog= $("#information_microblog").html();
		   	var information_address = $("#information_address").val();
		   	var information_postalcode = $("#information_postalcode").val();
		   	
		   	var sheng = $("#sheng option:selected").val();
	    	var shi = $("#shi option:selected").val();
	    	var xiang = $("#xiang option:selected").val();
	    	var information_province = null;
	    	var information_city = null;
	    	var information_area = null;
	    	if(sheng != ""){
	    		information_province = sheng;
	    		information_city = shi;
		    	information_area = xiang;
	    	}
        	var information_postalcode = $("#information_postalcode").val();
        	var information_microblog = $("#information_microblog").val();
		   	
		   	var contact_sex = $("#contact_sex").val();
		   	var communal_remarks = $("#communal_remarks").val();
		   	var usdata = {contact_type:contact_type,contact_name:contact_name,clientID:clientID,information_city:information_city,
		   			      departmentID:departmentID,contact_job:contact_job,contact_cellphone:contact_cellphone,information_area:information_area,
		   			      information_phone:information_phone,contact_email:contact_email,contact_sex:contact_sex,
		   			   information_microblog:information_microblog,information_address:information_address,information_postalcode:information_postalcode,contact_remarks:communal_remarks,
		   			   contact_id:contact_id,communal_id:communalID,information_id:informationID,information_province:information_province}; 
		   $.ajax({
				type:"post",
				url:"<%=basePath%>contact/updatecontact.action",
				data:usdata,
				success:function(data){
					alert(data);
					if(data == "修改成功")
					location.href="<%=basePath %>contact/findByIds.action?contact_id="+contact_id;
				},
				error:function(e){
					alert("发生未知错误请刷新页面");
				}

	   		 });
	   }
	   
    	function  updatePage(){
			
    		var clientName = $("#clientName").html();
			if(clientName == ""){
				return;
			}
        	$.ajax({
    			type:"post",
    			url:"<%=basePath %>contract/findClients.action",
    			success:function(data){
    				$("#clientID").html("");
    				var dep = eval("("+data+")");
   					for(var i=0;i<dep.length;i++){
   						var depar = dep[i];
   						
   						var depass = "";
   						if(clientName == depar.client_name){
   							depass = "<option value='"+depar.client_id+"' selected='selected'> "+ depar.client_name+"</option>";
   						}else{
   							depass = "<option value='"+depar.client_id+"'> "+ depar.client_name+"</option>";
   						}
   						$("#clientID").append(depass);
   					}
   					//$("#clientID").find("option:text="+clientName).attr("selected",true);

    			},
    			error:function(e){
    				alert("发生未知错误请刷新页面");
    			}

       		});
        	
        	var departmentName = $("#departmentName").html();
    		if(departmentName == ""){
    			return;
    		}
    		$.ajax({
 				type:"post",
 				url:"<%=basePath %>staff/findAllDeps.action",
 				success:function(staff_depar){
 					var dep = eval("("+staff_depar+")");
 					$("#departmentID").html("");
 					for(var i=0;i<dep.length;i++){
 						var depar = dep[i];
 						var depass = "";
 						if(depar.department_name == departmentName){
 	 						depass = "<option value='"+depar.department_id+"' selected='selected'>"+depar.department_name+"</option>";
 						}else{
 	 						depass = "<option value='"+depar.department_id+"'>"+depar.department_name+"</option>";
 						}
						$("#departmentID").append(depass);
 					}
 					//$("#departmentID").find("option:text="+departmentName).attr("selected",true);

 				},
 				error:function(e){
 					alert("发生未知错误请刷新页面");
 				}

	   		 });
    		var contactSex = $("#contactSex").html();
			$("#contact_sex option[value='"+contactSex+"']").attr("selected",true);
    	}
    	
    </script>
    <script language="javascript" defer>
		
		new PCAS("province3","city3","area3");
		
	</script>
</html>
